package com.liaowei.article.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liaowei.article.mapper.ArticleTagMapper;
import com.liaowei.article.service.ArticleTagService;
import com.liaowei.common.ErrorCode;
import com.liaowei.exception.CustomerException;
import com.liaowei.model.domain.ArticleTag;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
* @author LindaMan
* @description 针对表【wy_article_tag(文章-标签表)】的数据库操作Service实现
* @createDate 2023-05-06 23:31:37
*/
@Service
@RequiredArgsConstructor
public class ArticleTagServiceImpl extends ServiceImpl<ArticleTagMapper, ArticleTag>
    implements ArticleTagService{

    private final ArticleTagMapper articleTagMapper;


    /**
     * 根据标签id删除用户标签记录
     * @param tagId 标签id
     * @return 提示信息
     */
    @Override
    public String deleteByTagId(long tagId) {
        try {
            articleTagMapper.delete(Wrappers.lambdaQuery(ArticleTag.class).eq(ArticleTag::getTagId,tagId));
        } catch (Exception e) {
            throw new CustomerException(ErrorCode.SYSTEM_ERROR);
        }

        return "删除成功";
    }
}




